package cn.lyjuan.archetypes.bms.web.config;

import cn.lyjuan.archetypes.bms.common.entity.MgManage;
import cn.lyjuan.archetypes.bms.web.cst.StateConst;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

import java.util.Collection;

public class AppUserDetail extends User
{
    private MgManage realUser;

    public AppUserDetail(MgManage realUser, Collection<? extends GrantedAuthority> authorities)
    {
        // SpringSecurity会在用户验证成功后移除密码
        super(realUser.getName(), realUser.getPwd(), true, true, true,
                StateConst.OK.equals(realUser.getStatus()), authorities);
        this.realUser = realUser;
        // 防止内存泄露用户密码
        this.realUser.setPwd("******");
    }

    public MgManage getRealUser()
    {
        return realUser;
    }


}
